@import "../../styles/variables";
@import "../../styles/mixins";

.toggle {
  position: relative;
  display: inline-block;
  height: 20px;
  min-width: 40px;
  border-radius: 100px;
  background-color: $light-color04;
  vertical-align: middle;
  line-height: 20px;
  transition: all 0.36s;
  cursor: pointer;
  user-select: none;
  &:hover:after {
    background-color: $bg-color;
  }
  &.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    &:before {
      position: absolute;
      min-width: 44px;
      height: 24px;
      line-height: 20px;
      content: " ";
      pointer-events: none;
      z-index: 5;
    }
    &:after {
      cursor: not-allowed;
      pointer-events: none;
    }
    &:active:after {
      width: 18px;
      pointer-events: none;
    }
  }
  &.checked {
    background-color: $green-color03;
    &:hover {
      background-color: $green-color04;
    }
    &:active {
      background-color: $green-color05;
    }
    &:after {
      left: 100%;
      transform: translateX(calc(-100% - 5px)) translateY(-50%);
    }
    &:hover:after {
      background-color: $bg-color;
    }
    &:active:after {
      transform: translateX(calc(-100% - 5px)) translateY(-50%);
    }
    &:hover:active:after {
      background-color: $light-color02;
    }
  }
  &:after {
    position: absolute;
    top: 50%;
    width: 12px;
    height: 12px;
    left: 5px;
    border-radius: 18px;
    margin-left: 0;
    background-color: $white;
    box-shadow: 0 1px 2px 0 rgba(0, 41, 27, 0.08);
    transform: translateY(-50%);
    transition: all 0.36s cubic-bezier(0.78, 0.14, 0.15, 0.86);
    cursor: pointer;
    content: " ";
  }
  &:active:after {
    width: 24px;
  }
  &:active {
    background-color: $light-color04;
  }
  > span.text {
    line-height: 16px;
    font-size: 12px;
    font-weight: $font-bold;
    margin-left: 20px;
    margin-right: 8px;
    color: $white;

    &.checked {
      margin-left: 8px;
      margin-right: 20px;
    }
  }
}
